package org.darcy.service.impl;

import org.darcy.dao.BizAdMapper;
import org.darcy.entity.BizAd;
import org.darcy.framework.blog.business.enums.AdPositionEnum;
import org.darcy.framework.generic.GenericServiceImpl;
import org.darcy.service.BizAdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

@Service
public class BizAdServiceImpl extends GenericServiceImpl<BizAd> implements BizAdService {

	@Autowired
	private BizAdMapper bizAdMapper;

	@Override
	public BizAd getByPosition(AdPositionEnum positionEnum) {
		if (null == positionEnum) {
			return null;
		}
		QueryWrapper<BizAd> q = new QueryWrapper<BizAd>();
		q.eq("position", positionEnum.name());
		BizAd ad = this.bizAdMapper.selectOne(q);
		return ad;
	}

	@Override
	public BizAd getByPosition(String positionEnum) {
		if (null == positionEnum) {
			return null;
		}
		QueryWrapper<BizAd> q = new QueryWrapper<BizAd>();
		q.eq("position", positionEnum);
		BizAd ad = this.bizAdMapper.selectOne(q);
		return ad;
	}

}
